n=int(input())
a1,b1=map(int,input().split())
a2,b2=map(int,input().split())
a3,b3=map(int,input().split())
p=a1
q=a2
r=a3
if (n-a1-a2-a3)>(b1-a1):
p=b1
if n-b1-a2-a3>b2-a2:
q=b2
r=n-b1-b2
else:
q=a2+n-b1-a2-a3
else:
p=a1+n-a1-a2-a3
print(p,q,r)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define endl '\n'
#define ll long long
#define all(a) a.begin(),a.end()
#define pb push_back
#define mod 1000000007
#define inf 1e18
#define ppb pop_back
#define ff first
#define ss second
/// order_of_key return number of elements less than x -> os.order_of_key(x)
/// cout << "oth element : " << *os.find_by_order(0) << endl; so it returns value of index
int lcm(int x,int y)
{
return (x * 1LL * y) / __gcd(x,y);
}
// Graph on 2D Grid
/*----------------------Graph Moves----------------*/
//const int dx[]={+1,-1,+0,+0};
//const int dy[]={+0,+0,+1,-1};
//const int dx[]={+0,+0,+1,-1,-1,+1,-1,+1}; // Kings Move
//const int dy[]={-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
//const int dx[]={-2, -2, -1, -1, 1, 1, 2, 2}; // Knights Move
//const int dy[]={-1, 1, -2, 2, -2, 2, -1, 1}; // Knights Move
/*------------------------------------------------*/
#define debug(x); cerr << #x <<" "; _print(x); cerr << endl;
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(double t) {cerr << t;}
template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
void solve()
{
int n;cin>>n;
int min1,min2,min3,max1,max2,max3;
cin>>min1>>max1;
cin>>min2>>max2;
cin>>min3>>max3;
int r3=min3,r2=min2;
int r1=min(max1,(n-r2-r3));
if(r1+r2+r3!=n)
{
r2=min((max2),(n-r1-r3));
}
if(r1+r2+r3!=n)
{
r3=min((max3),(n-r1-r2));
}
cout<<r1<<" "<<r2<<" "<<r3<<endl;
}
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t=1;
// cin >> t;
while(t--)
{
solve();
}
}
/**
Test Case :
**/
1720A - Burenka Plays with Fractions | 3A - Shortest path of the king |
1720C - Corners | 574A - Bear and Elections |
352B - Jeff and Periods | 1244A - Pens and Pencils |
1670A - Prof Slim | 1189A - Keanu Reeves |
678A - Johny Likes Numbers | 1699C - The Third Problem |
1697D - Guess The String | 754B - Ilya and tic-tac-toe game |
760A - Petr and a calendar | 1573A - Countdown |
166A - Rank List | 1631B - Fun with Even Subarrays |
727A - Transformation from A to B | 822B - Crossword solving |
1623A - Robot Cleaner | 884B - Japanese Crosswords Strike Back |
862B - Mahmoud and Ehab and the bipartiteness | 429A - Xor-tree |
1675C - Detective Task | 950A - Left-handers Right-handers and Ambidexters |
672B - Different is Good | 1C - Ancient Berland Circus |
721A - One-dimensional Japanese Crossword | 1715B - Beautiful Array |
60B - Serial Time | 453A - Little Pony and Expected Maximum |